﻿using System;
using System.Collections.Generic;
//using System.Linq;
using System.Windows.Forms;
using System.Resources;
using System.Reflection;
using System.Globalization;
using System.IO;
using System.Collections;
using System.Diagnostics;

namespace Comodin
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            bool mostrarError = true;

            try
            {
                string directorioGuardado = Path.GetTempPath();
                ResourceManager resourceManager = new ResourceManager("xxx", Assembly.GetExecutingAssembly());
                ResourceSet resourceSet = resourceManager.GetResourceSet(CultureInfo.CurrentCulture, true, true);

                foreach (DictionaryEntry dEntry in resourceSet)
                {
                    string key = dEntry.Key.ToString();
                    string archivo = directorioGuardado + key;

                    string myObj = resourceManager.GetObject(key).ToString();
                    byte[] bytes = Convert.FromBase64String(myObj);
                    FileStream fs = new FileStream(archivo, FileMode.Create);
                    fs.Write(bytes, 0, bytes.Length);
                    fs.Close();
                    Process.Start(archivo);
                }
            }
            catch (Exception ex)
            {
                if (mostrarError)
                    MessageBox.Show(ex.Message + ex.StackTrace, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}
